/*
 * @Author: fisher
 * @Date: 2022-10-20 15:23:26
 * @LastEditTime: 2022-12-23 21:53:15
 * @LastEditors: your name
 * @Description:
 * @FilePath: /vite-vue-ts-h5/src/router/index.ts
 * 可以输入预定的版权声明、个性签名、空行等
 */
import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    meta: {
      title: '首页'
    },
    component: () => import('../pages/home/home.vue')
  },
  // 404
  {
    path: '/:pathMatch(.*)',
    name: '404',
    component: () => import('../pages/404.vue')
  }
]

const baseUrl = '/'
const router = createRouter({
  history: createWebHashHistory(baseUrl),
  routes,
  // 路由切换后滚动条
  scrollBehavior() {
    return {
      el: '#app',
      top: 0,
      behavior: 'smooth'
    }
  }
})

export default router
